import { z } from "zod";
// 定义请求体接口
export interface CreateRoomRequest {
  roomNumber: string;
  orderNo: string;
  messages?: string;
  inviteCode?: string;
  isDeleted?: boolean;
  ua?: string;
  fingerprintId?: string;
}
export interface InviteMember {
  id: string;
  roomNumber: string;
  updatedAt: number;
}
// 定义房间文档接口
export interface RoomDocument {
  roomNumber: string;
  inviteMembers: InviteMember[];
  orderNo: string;
  messages?: string;
  inviteCode?: string;
  isDeleted?: boolean;
  ua?: string;
  fingerprintId?: string;
  createdAt: number;
  updatedAt: number;
}
export interface RoomItemDocument extends RoomDocument {
  _id: string;
}

export const orderSchema = z.object({
  _id: z.string().optional(),
  inviteCode: z.string().optional(),
  messages: z.string().optional(),
  roomNumber: z
    .string()
    .optional()
    .refine((val) => !val || /^\d{2}-\d{2}-\d{4}$/.test(val), {
      message: "格式：如11号楼2单元1204填写 11-02-1204",
      path: ["roomNumber"],
    }),
  orderNo: z
    .string()
    .optional()
    .refine((val) => !val || /^\d+$/.test(val), {
      message: "只能输入数字",
      path: ["orderNo"],
    }),
  ua: z.string().optional(),
  fingerprintId: z.string().optional(),
});
export type OrderSchema = z.infer<typeof orderSchema>;

export interface SearchParams extends OrderSchema {
  page?: string;
  pageSize?: string;
  status?: string;
}
